'use strict';

const Controller = require('egg').Controller;

class userInfoController extends Controller {
  async login() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.login(ctx.request.body);
  }
  async register() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.register(ctx.request.body);
  }
  async verificationCode() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.verificationCode(ctx.request.body);
  }
  async retrievePassword() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.retrievePassword(ctx.request.body);
  }
  async logout() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.logout(ctx.request.body);
  }
  async updateUserType() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.updateUserType(ctx.request.body);
  }
  async updateUserStatus() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.updateUserStatus(ctx.request.body);
  }
  async getUserList() {
    const { ctx } = this;
    const sessionInfo = ctx.session.sessionInfo;
    if (!sessionInfo.id) {
      ctx.body = await ctx.service.returnBody.index(null, '请登录！');
    }
    ctx.body = await ctx.service.userInfo.getUserList(ctx.request.body);
  }
  async getLoginHistory() {
    const { ctx } = this;
    ctx.body = await ctx.service.userInfo.getLoginHistory(ctx.request.body);
  }
}

module.exports = userInfoController;
